package kr.hkit.PowerJava.chapter21;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class FileError {
	private int[] list;
	private static final int SIZE = 10;

	public FileError() {
		list = new int[SIZE];
		for (int i = 0; i < SIZE; i++){
			list[i] = i;
		writeList();
	}
	}
	private void writeList() {
       PrintWriter out = null;
       try {
		out = new PrintWriter(new FileWriter("outfile.txt"));
        for (int i = 0;i<SIZE; i++)
        	System.out.println("배열원소 "+i+" = "+list[i]);
       }catch (IOException e) {
		System.out.println("IOException");
       }catch (ArrayIndexOutOfBoundsException e){
    	   System.out.println("ArrayIndexOutOfBoundsException");
       }finally{
    	   if (out !=null)
    		   out.close();
    	   
	}
       
	}
public static void main(String[] args) {
	new FileError();
}
	
}
